import { getToken } from '@/utils/auth'
import { baseUrl } from '@/settings'

const defaultSettings = require('@/settings.js')

export default (_self) => {
  return {
    editBtn: true,
    delBtn: true,
    addBtn: true,
    labelWidth: 140,
    index: true,
    indexLabel: '序号',
    align: 'center',
    headerAlign: 'center',
    border: true,
    dialogWidth: '50%',
    stripe: false,
    searchShow: false,
    searchShowBtn: false,
    size: 'mini',
    // excelBtn: true,
    // selection: true,
    searchMenuSpan: 4,
    props: {
      label: 'label',
      value: 'value'
    },
    column: [
      {
        prop: 'name',
        label: '活动名称',
        rules: [
          {
            required: true,
            message: '请输入',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '图片',
        prop: 'img',
        headers: {
          Authorization: getToken()
        },
        limit: 1,
        type: 'upload',
        // listType: 'picture-img',
        // listType:'picture-card',
        propsHttp: {
          url: 'data'
        },
        formatter: (row, v) => {
          return v.split(',').map(item => baseUrl + '/' + item)
        },
        action: defaultSettings.uploadImg,
        rules: [
          {
            required: true,
            message: '请上传',
            trigger: 'blur'
          }
        ]
      },

      {
        prop: 'url',
        label: '地址',
        rules: [
          {
            required: true,
            message: '请输入',
            trigger: 'blur'
          }
        ]
      },
      {
        prop: 'order',
        label: '排序',
        type: 'number',
        tip: '填0为首页活动',
        rules: [
          {
            required: true,
            message: '请输入',
            trigger: 'blur'
          }
        ]
      },
      {
        prop: 'content',
        span: 24,
        label: '详情',
        formslot: true,
        rules: [
          {
            required: true,
            message: '请输入',
            trigger: 'blur'
          }
        ]
      }

    ]
  }
}
